package com.capgemini.remind.controller;

import com.capgemini.core.AjaxResponse;
import com.capgemini.core.PageList;
import com.capgemini.interceptor.DealerNumUtils;
import com.capgemini.remind.pojo.HqPromotion;
import com.capgemini.remind.pojo.RemindSms;
import com.capgemini.remind.service.RemindSmsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/remind/sms")
public class RemindSmsController {
	// 日志记录器
	public final Logger log = LoggerFactory.getLogger(this.getClass());
	@Autowired
	private RemindSmsService remindSmsService;

	@RequestMapping("/manage/{dealerNum}")
	public Object manage(@PathVariable("dealerNum") String dealerNum1) {
		String dealerNum = DealerNumUtils.getDealerNum();

		ModelAndView mv = new ModelAndView("/remind/remindSms.jsp");

		mv.addObject("dealerNum", dealerNum);

		Long smsQuantity = remindSmsService.querySmsQuantityByDealerNum(dealerNum);
		mv.addObject("smsQuantity", smsQuantity);


		return mv;
	}

	@RequestMapping("/list")
	@ResponseBody
	public Object list(PageList<RemindSms> pageList, RemindSms pojo) {
		AjaxResponse ajaxResponse = new AjaxResponse();

		pageList.setParam(pojo);
		remindSmsService.queryPage(pageList);

		ajaxResponse.setData(pageList);

		return ajaxResponse;
	}

	@RequestMapping("/quota/{dealerNum}")
	@ResponseBody
	public Object getQuotaByDealerNum(@PathVariable("dealerNum") String dealerNum1) {
		String dealerNum = DealerNumUtils.getDealerNum();
		AjaxResponse ajaxResponse = new AjaxResponse();

		Long smsQuantity = remindSmsService.querySmsQuantityByDealerNum(dealerNum);

		ajaxResponse.setData(smsQuantity);

		return ajaxResponse;
	}


}
